#include <stdio.h>
#include <assert.h>
void *my_memcpy(void *dest,const void *src,size_t count)
{
  assert(dest!=NULL&&src!=NULL);
  char *pDest=(char*)dest;
  const char *pSrc=(const char*)src;
  if(pSrc>=pDest||pDest>=pSrc+count)
  {
    while(count-->0)
    {
      *pDest++=*pSrc++;
    }
  }
  else
  {
    pDest+=(count-1);
    pSrc+=(count-1);
    while(count-->0)
    {
      *pDest--=*pSrc--;
    }
  }
  return pDest;

}

int main()
{
  char ar[]="abcdefghij";
  printf("%s\n",ar);
  my_memcpy(ar+2,ar,4);
  printf("%s\n",ar);
  return 0;
}
